#include <iostream>
#include <string>
#include <fstream>
#include <stack>
#include <map>
#include <vector>
#include <ctype.h>

using namespace std;


class CppVar{
public:

	CppVar():lineNo(0){


	}

	void findVar(const char * fname);

	void printResult()
	{
		map<string, vector<int>>::iterator itr = str2lines.begin();
		for (; itr != str2lines.end(); ++itr)
		{
			const vector<int> & ivec = itr->second;
			cout << itr->first << ": ";
			for (int i = 0; i < ivec.size(); ++i)
			{
				cout << ivec[i] << " ";
			}

			cout << endl;

		}

	}

private:

	bool isSemicolon(string str);

	bool isVar(stack<string> & aStack, string & var);

	bool isValidVar(const string & str)
	{
		int i = 0;

		for ( i = 0; i < str.size(); ++i)
		{
			if (!isalpha(str[i]) && !isdigit(str[i]))
				break;
		}

		if (i != str.size() - 1 || isdigit(str[0]) || str == "break;" || str == "continue;")
			return false;

		return true;
			
	}

	bool isValidType(const string & str)
	{
		int i = 0;
		if (ispunct(str[i]))
			return false;
		if (str == "namespace")
			return false;
		if (str == "return")
			return false;
		return true;


	}

	fstream fin;

	string str;

	stack<string> strStack;

	int lineNo;

	map<string, vector<int>> str2lines;

};